package cn.openea.perpartner.meily.rabbit.factory;

import cn.openea.perpartner.meily.rabbit.service.BusinessService;
import org.springframework.stereotype.Component;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author Weird077
 * @description TODO
 * @date 2023-02-27 15:33
 */
@Component
public class BusinessServiceFactory {
    /**
     * 存放策略实现类
     */
    private static final Map<String, BusinessService> BUSINESS_SERVICE_MAP = new ConcurrentHashMap<>(255);

    /**
     * 通过beanName找service
     */
    public static BusinessService getHandler(String beanName) {
        return BUSINESS_SERVICE_MAP.get(beanName);
    }

    /**
     * DelayService 的实现类放到map中
     */
    public static void register(String beanName,BusinessService businessService){
        BUSINESS_SERVICE_MAP.put(beanName,businessService);
    }
}
